@extends('layouts.app')
@section('title', '添加权限')

@section('content')
    <div class="tabs center-block">
        <form class="form-horizontal"  id="addForm" role="form" action="{{ route('users.permission', $user) }}" method="post">
        <div class="form-group">
            <label  class="col-sm-4 control-label">用户</label>
            <div class="col-sm-6">
                <input type="text" class="form-control"  name="username" id="username" value="{{ $user->name }}" disabled>
            </div>
        </div>
        <div class="form-group">
            <label  class="col-sm-4 control-label">职务</label>
            <div class="col-sm-6">
                <select class="form-control" name="auth">
                    @foreach($user->authList() as $k => $v)
                        <option value="{{ $k }}" @if($k == $user->auth) selected @endif>{{ $v }}</option>
                    @endforeach
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="lastname" class="col-sm-4 control-label">权限id</label>
            <div class="col-sm-6">

                @foreach($permissions as $v)
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="permissions[]" value="{{ $v->name }}" @if($user->can($v->name)) checked @endif>
                        {{ $v->desc_name }}
                    </label>
                </div>
                @endforeach

            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-4 col-sm-8">
                <button type="submit" class="btn btn-default">add</button>
            </div>
        </div>
        {{ csrf_field() }}
    </form>
    </div>
    <link rel="stylesheet" type="text/css"  href="{{ asset('css/users/create.css') }}"/>
@endsection
